<?php
/* @var $this SurveyUserController */
/* @var $model SurveyUser */

$this->breadcrumbs = array (
		Yii::t ( 'base', 'Survey User' ) => array (
				'index' 
		),
		Yii::t ( 'base', 'Manage' ) 
);

Yii::app ()->clientScript->registerScript ( 'search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#survey-user-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
" );
?>

<h1><?php echo Yii::t('base','Manage');echo Yii::t('base','Survey User');?> </h1>

<?php

echo Yii::t ( 'base', '<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>' );
?>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display: none">
<?php

$this->renderPartial ( '_search', array (
		'model' => $model 
) );

?>

</div>
<!-- search-form -->
<script type="text/javascript">
function gettype($suid)
{var data=new Array();
//document.write($suid);
//alert("jeiofjijfi");
$.post("<?php echo Yii::app()->createUrl('SurveyUser/sendSms'); ?>",{'suid':$suid}, 
		
		   function (data) {

      if (data.indexOf("ok,")>0) {
    	  alert('<?php echo Yii::t('base', 'SMS Send Success!');?>');
			//location.href ="../surveyUser/admin";
    	 
      }
      else
      {
    	  	 
			 alert('<?php echo Yii::t('base', 'SMS Send Fail!');?>');
        }
});
}
</script>
<script type="text/javascript">
function gettype1($suid)
{var data=new Array();
$.post("<?php echo Yii::app()->createUrl('SurveyUser/SendInform');?>", {'suid':$suid}, 
		   function (data) {
      if (data.indexOf("ok,")>0) {
       alert('<?php echo Yii::t('base', 'Email Send Success!');?>');
			//location.href ="../surveyUser/admin";
      }
      else
      {
    	  alert('<?php echo Yii::t('base', 'Email Send Fail!');?>');
        }
});
}
</script>
<a class="btn btn-small create" title="<?php echo Yii::t('base', 'Export Survey User');?>" href="javascript:box();"><?php echo Yii::t('base', 'Export Survey User');?></a>
<?php
$this->widget ( 'zii.widgets.grid.CGridView', array (
		'id' => 'survey-user-grid',
		'dataProvider' => $model->search (),
		
		// 'filter'=>$model,
		'itemsCssClass' => 'responsive table table-striped table-bordered',
		'pager'=>array('class'=>'CLinkPager','hiddenPageCssClass'=>'','firstPageCssClass'=>'first paginate_button','htmlOptions'=>array('class'=>'dataTables_paginate paging_full_numbers"'),'header'=>""),
		'pagerCssClass'=>'pagination',
		'cssFile'=>false,
		'template'=>'{items}{summary}{pager}',
		'columns' => array (
				// 'suid',
				array (
						'name' => 'partner_id',
						'value' => 'User::model()->findByPk($data->partner_id)->user_name' 
				),
				// array('name'=>'activety_code','value'=>'GiftPassword::model()->getActivityName($data->activety_code)'),
				// 'suid',
				'first_name',
				'last_name',
				'email',
				// 'favo',
				'mobile',
				// 'winning_status',
				// 'id_number',
				// array (
				// 'name' => 'award_address_id',
				// 'value' => 'Activity::model()->getAddressList($data->award_address_id)',
				// 'visible' => Yii::app ()->user->level () == 9
				// ),
				array (
						'name' => 'award_address_id',
						'value' => 'Activity::model()->getAddressLists($data->award_address_id,$data->partner_id)',
						'visible' => Yii::app ()->user->level () == 1 
				),
				array (
						'name' => 'winning_status',
						'value' => 'SurveyUser::model()->switchStatus($data->winning_status)' 
				),
				// 'password',
				array (
						'name' => 'sms_status',
						'value' => 'SurveyUser::model()->SmsSwitchStatus($data->sms_status)' 
				),
				// 'IP',
				array (
						'class' => 'CButtonColumn',
						'header' => Yii::t ( 'base', 'Operate' ),
						'updateButtonImageUrl' => array (
								'class' => 'gicon-edit' 
						),
						'updateButtonOptions' => array (
								'class' => 'btn btn-small' 
						),
						
						'deleteButtonImageUrl' => array (
								'class' => 'gicon-edit' 
						),
						'deleteButtonOptions' => array (
								'class' => 'btn btn-inverse btn-small' 
						),
						
						'viewButtonImageUrl' => array (
								'class' => 'gicon-edit' 
						),
						'viewButtonOptions' => array (
								'class' => 'btn btn-small' 
						),
						'template' => '{delete}{view}{update}',
				)
				,
				array (
						'class' => 'CButtonColumn',
						'header' => Yii::t ( 'base', 'Resend SMS' ),
						
						'template' => '{Winner Reminder}{Prize Code}',
						
						'buttons' => array (
								'Winner Reminder' => array (
										'label' => Yii::t ( 'base', 'Winner Reminder' ),
										'url' => '"javascript:gettype1(\"".$data->suid."\");"',
										'options' => array (
												'class' => 'btn btn-small' 
										),
										'visible' => '$data->winning_status==1' 
								),
								'Prize Code' => array (
										'label' => Yii::t ( 'base', 'Prize Code' ),
										// 'url' => 'Yii::app()->createUrl("SurveyUser/SendSms",array("suid"=>$data->suid))',
										'options' => array (
												'class' => 'btn btn-small' 
										// 'onclick'=>"gettype()".$model->suid,
																				),
										'url' => '"javascript:gettype(\"".$data->suid."\");"',
										'visible' => '$data->winning_status==1' 
								),
								'Export' => array (
										'label' => Yii::t ( 'base', 'Export' ),
										'url' => 'yii::app()->createUrl("/SurveyUser/export",array("id"=>$data->suid)) ',
										'options' => array (
												'class' => 'btn btn-small' 
										), 
								), 
						)
						 
				)
				 
		)
		 
) );

$rs = PotentialCustomersList::model()->getActivityList();
?>
<!-- 弹出窗口 -->
<div id="myModal" style="display: none;">
	<form id="upForm" name="upForm" action="<?php echo Yii::app()->createUrl("/surveyUser/Export");?>" method="get"> 
		<table>
			<tr>
				<td><?php echo Yii::t('base', 'Select Events')?>:</td>
				<td>
					<select id="activity_code" name="activity_code">
					<?php 
						for ($i=0; $i<count($rs); $i++){
					?>
						<option value="<?php echo $rs[$i][activity_code];?>"><?php echo $rs[$i][title];?></option>
					<?php } ?>
					</select>
				</td>
			</tr>
			<tr>
				<td><input type="submit" name="submitBtn" id="submitBtn" value="<?php echo Yii::t('base', 'Export');?>" /> </td>
			</tr>
		</table>
	</form>  
		<span id="upload_repairinfo_success" style="color:blue;"></span> 
</div>
<!-- 弹出窗口 -->
<script type="text/javascript">
function box(){
			$.fancybox.open({
				href : '#myModal',
				type : 'inline',
				maxWidth	: 400,
				maxHeight	: 180,
				fitToView	: false,
				width		: '400',
				height		: '180',
				autoSize	: false,
				openEffect	: 'none',
				closeBtn	: true,//正式发布时请将true,改为false,不显示关闭按钮
				closeClick	: false,
				helpers : {
					overlay : null,
				}
		});
}
</script>